#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include "personnel.h"
//#ifndef EVENTS_H_
#include "events.h"
//#endif
#include "patient.h"
#include "gestion_des_capteurs.h"
#include "string.h"
#include <stdlib.h>
#include <stdio.h>


void
on_button1_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{  		/*GtkWidget *window1;
                GtkWidget *window2;
                window1 = lookup_widget(objet_graphique,"window1");
                gtk_widget_hide(window1);
                window2 = create_window2();
		gtk_widget_show(window2);*/
	
	char buf[10000]="";
	int mp ;
	char login[20];
	char Login[20]="ebola";
	int Mp=123456;
	

	GtkWidget *entry1;
	GtkWidget *entry2;
	GtkWidget *label73;
	GtkWidget *window1;


entry1 = lookup_widget(objet_graphique, "entry1");
entry2 = lookup_widget(objet_graphique, "entry2");

strcpy(login,gtk_entry_get_text(GTK_ENTRY(entry1)));
mp= atoi( gtk_entry_get_text(GTK_ENTRY(entry2)));

if ((strcmp(login,Login)==0)&&(mp==Mp))
{		GtkWidget *window1;
                GtkWidget *window2;
                window1 = lookup_widget(objet_graphique,"window1");
                gtk_widget_hide(window1);
                window2 = create_window2();
		gtk_widget_show(window2);}
else 
{
sprintf(buf,"le mot de passe que vous avez saisi est faux ") ;
label73= lookup_widget(objet_graphique, "label73");
gtk_label_set_text(GTK_LABEL(label73),buf);
}


}


void
on_button2_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

 		GtkWidget *window2;
                GtkWidget *window3;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window3 = create_window3();
		gtk_widget_show(window3);

}


void
on_button3_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

		GtkWidget *window2;
                GtkWidget *window4;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window4 = create_window4();
		gtk_widget_show(window4);


}


void
on_button4_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

		GtkWidget *window2;
                GtkWidget *window10;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(GTK_WIDGET(window2));
                window10 = create_window10();
		gtk_widget_show(window10);


}


void
on_button5_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

		GtkWidget *window2;
                GtkWidget *window16;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window16 = create_window16();
		gtk_widget_show(window16);


}


void
on_button6_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
   
gtk_main_quit();

}


void
on_button7_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)

    {char alerte [50000] ;
char medecin[50000] ;


GtkWidget * label7 ;
GtkWidget * label8;
label7= lookup_widget(objet_graphique, "label7") ;
label8= lookup_widget(objet_graphique, "label8") ;
afficheridentificateur( "fichier_personnel",  alerte , medecin);

gtk_label_set_text(GTK_LABEL(label7), alerte) ;
gtk_label_set_text(GTK_LABEL(label8),medecin) ;
}


void
on_button8_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)

{
char iden[200] ;
char lechemin[50] ;
GtkWidget * entry3;
GtkWidget * label11;
label11= lookup_widget(objet_graphique , "label11") ;
entry3=lookup_widget(objet_graphique, "entry3") ;
strcpy(iden,gtk_entry_get_text(GTK_ENTRY(entry3))) ;
rechercheparcours(lechemin , iden) ;

gtk_label_set_text(GTK_LABEL(label11), lechemin) ;
}



void
on_button9_clicked                     (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

                GtkWidget *window3;
                GtkWidget *window2;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window2 = create_window2();
		gtk_widget_show(window2);

}


void
on_button10_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window4;
                GtkWidget *window5;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void
on_button12_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window4;
                GtkWidget *window7;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window7 = create_window7();
		gtk_widget_show(window7);
}


void
on_button11_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window4;
                GtkWidget *window6;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window6 = create_window6();
		gtk_widget_show(window6);
}




void
on_button13_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window4;
                GtkWidget *window8;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window8 = create_window8();
		gtk_widget_show(window8);

personnel p,per;
	char fichier_personnel[]="fichier_personnel.txt";
	GtkWidget *label30;
	label30= lookup_widget(GTK_WIDGET(window8),"label30");

	char archive_personnel[]="archive_personnel.txt";
	GtkWidget *label71;
	label71= lookup_widget(GTK_WIDGET(window8),"label71");
	
	char temp[10000]="";
	char temp1[10000]="";
	char buf[200]="";
	char Buf[200]="";	
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="CIN: ";
	char buf3[50]="Telephone: ";
	char buf4[50]="mail: ";
	char buf5[50]="Date de naissance: ";
	char buf6[50]="statue: ";
	char buf7[50]="Date d'embauche: ";
        char buf8[50]="Photo: ";
	
FILE*f;
FILE*a;

f=fopen(fichier_personnel,"rb");
if(f!=NULL)
{
strcpy (p.nom," " ) ;
strcpy(p.prenom," ");
p.cin=0;
p.telephone=0;
strcpy(p.mail," ");
p.date_naissance.jour=0;
p.date_naissance.mois=0;
p.date_naissance.annee=0;
strcpy(p.statue," ");
p.date_embauche.jour=0;
p.date_embauche.mois=0;
p.date_embauche.annee=0;
strcpy(p.photo," ");


   fread(&p,sizeof(personnel),1,f);
   do
  {
   sprintf(buf,"%s:%s %s:%s %s:%d %s:%d %s:%s %s: %d/%d/%d %s:%s %s: %d/%d/%d %s:%s ",buf0,p.nom,buf1,p.prenom,buf2,p.cin,buf3,p.telephone,buf4,p.mail,buf5,p.date_naissance.jour,p.date_naissance.mois,p.date_naissance.annee,
buf6,p.statue,buf7,p.date_embauche.jour,p.date_embauche.mois,p.date_embauche.annee,buf8,p.photo);
 strcat(temp,buf);
strcat(temp,"\n");
 } while(((fread(&p,sizeof(personnel),1,f))!=0)&&(feof(f)!=1));
}
fclose(f);

a=fopen(archive_personnel,"rb");
if(a!=NULL)
{
strcpy (per.nom," " ) ;
strcpy(per.prenom," ");
per.cin=0;
per.telephone=0;
strcpy(per.mail," ");
per.date_naissance.jour=0;
per.date_naissance.mois=0;
per.date_naissance.annee=0;
strcpy(per.statue," ");
per.date_embauche.jour=0;
per.date_embauche.mois=0;
per.date_embauche.annee=0;
strcpy(per.photo," ");


   fread(&per,sizeof(personnel),1,a);
   do
  {
   sprintf(Buf,"%s:%s %s:%s %s:%d %s:%d %s:%s %s: %d/%d/%d %s:%s %s: %d/%d/%d %s:%s ",buf0,per.nom,buf1,per.prenom,buf2,per.cin,buf3,per.telephone,buf4,per.mail,buf5,per.date_naissance.jour,per.date_naissance.mois,per.date_naissance.annee,
buf6,per.statue,buf7,per.date_embauche.jour,per.date_embauche.mois,per.date_embauche.annee,buf8,per.photo);
 strcat(temp1,Buf);
strcat(temp1,"\n");
 } while(((fread(&per,sizeof(personnel),1,a))!=0)&&(feof(a)!=1));
}
fclose(a);

gtk_label_set_text(GTK_LABEL(label30),temp);
gtk_label_set_text(GTK_LABEL(label71),temp1);
	
}


void
on_button14_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
initialiser_personnel("fichier_personnel.txt");
}


void
on_button15_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window4;
                GtkWidget *window9;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window9 = create_window9();
		gtk_widget_show(window9);
}


void
on_button16_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
initialiser_personnel_archive("archive_personnel.txt");
}


void
on_button17_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

  		GtkWidget *window4;
                GtkWidget *window2;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window2 = create_window2();
		gtk_widget_show(window2);

}


void
on_button18_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
personnel p;

	char fichier_personnel;
	
	GtkWidget *entry4;
	GtkWidget *entry5;
	GtkWidget *entry6;
	GtkWidget *entry7;
	GtkWidget *entry8;
	GtkWidget *entry37;
	GtkWidget *entry38;
	GtkWidget *entry39;
	GtkWidget *entry40;
	GtkWidget *entry41;
	GtkWidget *entry42;
	GtkWidget *entry43;
	GtkWidget *entry9;
        GtkWidget *entry5000;
	

	entry4= lookup_widget(objet_graphique,"entry4");
	entry5= lookup_widget(objet_graphique,"entry5");
	entry6= lookup_widget(objet_graphique,"entry6");
	entry7= lookup_widget(objet_graphique,"entry7");
	entry8= lookup_widget(objet_graphique,"entry8");
	entry37= lookup_widget(objet_graphique,"entry37");
	entry38= lookup_widget(objet_graphique,"entry38");
	entry39= lookup_widget(objet_graphique,"entry39");
	entry40= lookup_widget(objet_graphique,"entry40");
	entry41= lookup_widget(objet_graphique,"entry41");
	entry42= lookup_widget(objet_graphique,"entry42");
	entry43= lookup_widget(objet_graphique,"entry43");
	entry9= lookup_widget(objet_graphique,"entry9");
        entry5000= lookup_widget(objet_graphique,"entry5000");


	
	strcpy(p.nom,gtk_entry_get_text(GTK_ENTRY(entry4)));
	strcpy(p.prenom,gtk_entry_get_text(GTK_ENTRY(entry5)));
	p.cin= atoi( gtk_entry_get_text(GTK_ENTRY(entry6)));
        p.telephone= atoi( gtk_entry_get_text(GTK_ENTRY(entry7)));
        strcpy(p.mail,gtk_entry_get_text(GTK_ENTRY(entry8)));
	p.date_naissance.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry37)));
	p.date_naissance.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry38)));
	p.date_naissance.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry39)));
        strcpy(p.statue,gtk_entry_get_text(GTK_ENTRY(entry40)));
        p.date_embauche.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry41)));
	p.date_embauche.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry42)));
	p.date_embauche.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry43)));
        strcpy(p.photo,gtk_entry_get_text(GTK_ENTRY(entry9)));
     


           strcpy(p.matricule,gtk_entry_get_text(GTK_ENTRY(entry5000)));
        

        

      


	Enregistrer_personnel("fichier_personnel.txt",&p);
}


void
on_button19_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{


		GtkWidget *window5;
                GtkWidget *window4;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window4 = create_window4();
		gtk_widget_show(window4);

}


void
on_button20_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
personnel p ;
int cin;


int r=0;
char aux[100000]="";
char buf[1000]="";
char buf0[50]="Nom";
char buf1[50]="Prenom";
char buf2[50]="Cin";
char buf3[50]="Mail";
char buf4[50]="Telephone";
char buf5[50]="Statut";
char buf6[50]="Photo";
char buf8[50]="Date d'embauche";
char buf7[50]="Date de naissance";
char buf9[50]="";
char buf10[50]="";

GtkWidget *entry10;
GtkWidget *label25;
GtkWidget *window6;

entry10 = lookup_widget(objet_graphique, "entry10");


cin = atoi(gtk_entry_get_text(GTK_ENTRY(entry10)));

r=rechercher_personnel("fichier_personnel.txt",cin,&p);
if (r==1)
{
sprintf(aux, "%s: %s  %s: %s  %s: %d %s: %s %s: %d %s: %s %s: %s %s: %d/%d/%d %s: %d/%d/%d", buf0, p.nom, buf1,p.prenom, buf2, p.cin,buf3,p.mail,buf4,p.telephone,buf5,p.statue,buf6,p.photo,buf7,p.date_naissance.jour,p.date_naissance.mois,p.date_naissance.annee,buf8,p.date_embauche.jour,p.date_embauche.mois,p.date_embauche.annee);
label25= lookup_widget(objet_graphique, "label25");
gtk_label_set_text(GTK_LABEL(label25),aux);
}
else
{
sprintf(aux,"le personnel n'existe pas ") ;
label25= lookup_widget(objet_graphique, "label25");
gtk_label_set_text(GTK_LABEL(label25),aux);

}
}

void
on_button21_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

		GtkWidget *window6;
                GtkWidget *window4;
                window6 = lookup_widget(objet_graphique,"window6");
                gtk_widget_hide(window6);
                window4 = create_window4();
		gtk_widget_show(window4);


}


void
on_button22_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

}


void
on_button23_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

}


void
on_button24_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window7;
                GtkWidget *window4;
                window7 = lookup_widget(objet_graphique,"window7");
                gtk_widget_hide(window7);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void
on_button25_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

		GtkWidget *window8;
                GtkWidget *window4;
                window8 = lookup_widget(objet_graphique,"window8");
                gtk_widget_hide(window8);
                window4 = create_window4();
		gtk_widget_show(window4);


}


void
on_button26_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
 int cin_cherche;
        GtkWidget *entry12;
        entry12= lookup_widget(objet_graphique,"entry12");
        cin_cherche= atoi( gtk_entry_get_text(GTK_ENTRY(entry12)));
        archiver_personnel( "fichier_personnel.txt", "archive_personnel.txt",cin_cherche);
}


void
on_button27_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

		GtkWidget *window9;
                GtkWidget *window4;
                window9 = lookup_widget(objet_graphique,"window9");
                gtk_widget_hide(window9);
                window4 = create_window4();
		gtk_widget_show(window4);


}


void
on_button28_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window10;
                GtkWidget *window11;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window11 = create_window11();
		gtk_widget_show(window11);
}


void
on_button29_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window10;
                GtkWidget *window12;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window12 = create_window12();
		gtk_widget_show(window12);
}


void
on_button30_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window10;
                GtkWidget *window13;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window13 = create_window13();
		gtk_widget_show(window13);	
}


void
on_button31_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window10;
                GtkWidget *window14;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window14 = create_window14();
		gtk_widget_show(window14);

patient pa,p;
	char fichier_patient[]="fichier_patient.txt";
	GtkWidget *label50;
	label50= lookup_widget(GTK_WIDGET(window14),"label50");

	char archive_patient[]="archive_patient.txt";
	GtkWidget *label75;
	label75= lookup_widget(GTK_WIDGET(window14),"label75");


	char temp[10000]="";
	char temp1[10000]="";
	char buf[200]="";
	char Buf[200]="";	
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="Telephone: ";
	char buf3[50]="CIN: ";
	char buf4[50]="Date de naissance: ";
	char buf5[50]="Date de contaminaion: ";
	char buf6[50]="Date d'entree: ";
	char buf7[50]="Date de sortie: ";
	
FILE*f;
FILE*a;
f=fopen(fichier_patient,"rb");
if(f!=NULL)
{
strcpy (pa.nom," " ) ;
strcpy(pa.prenom," ");
pa.telephone=0;
pa.cin=0;
pa.date_naissance.jour=0;
pa.date_naissance.mois=0;
pa.date_naissance.annee=0;
pa.date_contamination.jour=0;
pa.date_contamination.mois=0;
pa.date_contamination.annee=0;
pa.date_entre.jour=0;
pa.date_entre.mois=0;
pa.date_entre.annee=0;
pa.date_sortie.jour=0;
pa.date_sortie.mois=0;
pa.date_sortie.annee=0;






   fread(&pa,sizeof(patient),1,f);
   do
  {
   sprintf(buf,"%s: %s  %s: %s  %s: %d  %s: %d  %s: %d/%d/%d %s: %d/%d/%d %s: %d/%d/%d %s: %d/%d/%d ",buf0,pa.nom,buf1,pa.prenom,buf2,pa.telephone,buf3,pa.cin,buf4,pa.date_naissance.jour,pa.date_naissance.mois,pa.date_naissance.annee,buf5,
pa.date_contamination.jour,pa.date_contamination.mois,pa.date_contamination.annee,buf6,pa.date_entre.jour,pa.date_entre.mois,pa.date_entre.annee,
buf7,pa.date_sortie.jour,pa.date_sortie.mois,pa.date_sortie.annee);
 strcat(temp,buf);
strcat(temp,"\n");
 }
   while(((fread(&pa,sizeof(patient),1,f))!=0)&&(feof(f)!=1));
}

fclose(f);

a=fopen(archive_patient,"rb");
if(a!=NULL)
{
strcpy (p.nom," " ) ;
strcpy(p.prenom," ");
p.telephone=0;
p.cin=0;
p.date_naissance.jour=0;
p.date_naissance.mois=0;
p.date_naissance.annee=0;
p.date_contamination.jour=0;
pa.date_contamination.mois=0;
p.date_contamination.annee=0;
p.date_entre.jour=0;
p.date_entre.mois=0;
p.date_entre.annee=0;
p.date_sortie.jour=0;
p.date_sortie.mois=0;
p.date_sortie.annee=0;


   fread(&p,sizeof(patient),1,a);
   do
  {
   sprintf(Buf,"%s: %s  %s: %s  %s: %d  %s: %d  %s: %d/%d/%d %s: %d/%d/%d %s: %d/%d/%d %s: %d/%d/%d ",buf0,p.nom,buf1,p.prenom,buf2,p.telephone,buf3,p.cin,buf4,p.date_naissance.jour,p.date_naissance.mois,p.date_naissance.annee,buf5,
p.date_contamination.jour,p.date_contamination.mois,p.date_contamination.annee,buf6,p.date_entre.jour,p.date_entre.mois,p.date_entre.annee,
buf7,p.date_sortie.jour,p.date_sortie.mois,p.date_sortie.annee);
 strcat(temp1,Buf);
strcat(temp1,"\n");
 } while(((fread(&p,sizeof(patient),1,a))!=0)&&(feof(a)!=1));
}
fclose(a);





gtk_label_set_text(GTK_LABEL(label50),temp);
gtk_label_set_text(GTK_LABEL(label75),temp1);





}


void
on_button32_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
initialiser_patient("fichier_patient.txt");
}


void
on_button33_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window10;
                GtkWidget *window15;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window15 = create_window15();
		gtk_widget_show(window15);
}


void
on_button34_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window10;
                GtkWidget *window22;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window22 = create_window22();
		gtk_widget_show(window22);
}


void
on_button35_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
initialiser_patient_archive("archive_patient.txt");
}


void
on_button36_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)


{
   		GtkWidget *window10;
                GtkWidget *window2;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window2 = create_window2();
		gtk_widget_show(window2);
            
  }


void
on_button37_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{ 
 patient pa;

	char fichier_patient;
	
	GtkWidget *entry13;
	GtkWidget *entry14;
	GtkWidget *entry15;
	GtkWidget *entry16;
	GtkWidget *entry25;
	GtkWidget *entry26;
	GtkWidget *entry27;
	GtkWidget *entry28;
	GtkWidget *entry29;
	GtkWidget *entry30;
	GtkWidget *entry31;
	GtkWidget *entry32;
	GtkWidget *entry33;
	GtkWidget *entry34;
	GtkWidget *entry35;
	GtkWidget *entry36;


	entry13= lookup_widget(objet_graphique,"entry13");
	entry14= lookup_widget(objet_graphique,"entry14");
	entry15= lookup_widget(objet_graphique,"entry15");
	entry16= lookup_widget(objet_graphique,"entry16");
	entry25= lookup_widget(objet_graphique,"entry25");
	entry26= lookup_widget(objet_graphique,"entry26");
	entry27= lookup_widget(objet_graphique,"entry27");
	entry28= lookup_widget(objet_graphique,"entry28");
	entry29= lookup_widget(objet_graphique,"entry29");
	entry30= lookup_widget(objet_graphique,"entry30");
	entry31= lookup_widget(objet_graphique,"entry31");
	entry32= lookup_widget(objet_graphique,"entry32");
	entry33= lookup_widget(objet_graphique,"entry33");
	entry34= lookup_widget(objet_graphique,"entry34");
	entry35= lookup_widget(objet_graphique,"entry35");
	entry36= lookup_widget(objet_graphique,"entry36");

	strcpy(pa.nom,gtk_entry_get_text(GTK_ENTRY(entry13)));
	strcpy(pa.prenom,gtk_entry_get_text(GTK_ENTRY(entry14)));
	pa.telephone= atoi( gtk_entry_get_text(GTK_ENTRY(entry15)));
	pa.cin= atoi( gtk_entry_get_text(GTK_ENTRY(entry16)));
	pa.date_naissance.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry25)));
	pa.date_naissance.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry26)));
	pa.date_naissance.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry27)));
        pa.date_contamination.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry28)));
	pa.date_contamination.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry28)));
	pa.date_contamination.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry29)));
       	pa.date_contamination.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry30)));
	pa.date_entre.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry31)));
	pa.date_entre.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry32)));
	pa.date_entre.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry33)));
	pa.date_sortie.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry34)));
	pa.date_sortie.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry35)));
	pa.date_sortie.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry36)));

	Enregistrer_patient("fichier_patient.txt",&pa);

  




}


void
on_button38_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

		GtkWidget *window11;
                GtkWidget *window10;
                window11 = lookup_widget(objet_graphique,"window11");
                gtk_widget_hide(window11);
                window10 = create_window10();
		gtk_widget_show(window10);

}


void
on_button39_clicked                   (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
patient p ;
int cin;


int r=0;
char aux[100000]="";
char buf[1000]="";
char buf0[50]="Nom";
char buf1[50]="Prenom";
char buf2[50]="Cin";
char buf3[50]="Telephone";
char buf4[50]="Date de naissance";
char buf6[50]="date dentre";
char buf7[50]="date de sorti";
char buf5[50]="Date de contamination";


GtkWidget *entry17;
GtkWidget *label45;
GtkWidget *window12;

entry17 = lookup_widget(objet_graphique, "entry17");


cin = atoi(gtk_entry_get_text(GTK_ENTRY(entry17)));

r=rechercher_patient("fichier_patient.txt",cin,&p);
if (r==1)
{
sprintf(aux, "%s: %s  %s: %s  %s: %d  %s: %d  %s: %d/%d/%d %s: %d/%d/%d %s: %d/%d/%d %s: %d/%d/%d", buf0, p.nom, buf1,p.prenom, buf2, p.cin,buf3,p.telephone,buf4,p.date_naissance.jour,p.date_naissance.mois,p.date_naissance.annee,buf5,p.date_contamination.jour,p.date_contamination.mois,p.date_contamination.annee,buf6,p.date_entre.jour,p.date_entre.mois,p.date_entre.annee,buf7,p.date_entre.jour,p.date_sortie.mois,p.date_sortie.annee);
label45= lookup_widget(objet_graphique, "label45");
gtk_label_set_text(GTK_LABEL(label45),aux);
}
else
{
sprintf(aux,"le patient n'existe pas ") ;
label45= lookup_widget(objet_graphique, "label45");
gtk_label_set_text(GTK_LABEL(label45),aux);

}
}


void
on_button40_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window12;
                GtkWidget *window10;
                window12 = lookup_widget(objet_graphique,"window12");
                gtk_widget_hide(window12);
                window10 = create_window10();
		gtk_widget_show(window10);
}


void
on_button43_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window13;
                GtkWidget *window10;
                window13 = lookup_widget(objet_graphique,"window13");
                gtk_widget_hide(window13);
                window10 = create_window10();
		gtk_widget_show(window10);
}


void
on_button42_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

}


void
on_button41_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

}


void
on_button44_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window14;
                GtkWidget *window10;
                window14 = lookup_widget(objet_graphique,"window14");
                gtk_widget_hide(window14);
                window10 = create_window10();
		gtk_widget_show(window10);
}


void
on_button45_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
int cin_cherchee;
        GtkWidget *entry19;
        entry19= lookup_widget(objet_graphique,"entry19");
        cin_cherchee= atoi( gtk_entry_get_text(GTK_ENTRY(entry19)));
        archiver_patient( "fichier_patient.txt", "archive_patient.txt",cin_cherchee);
}


void
on_button46_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window15;
                GtkWidget *window10;
                window15 = lookup_widget(objet_graphique,"window15");
                gtk_widget_hide(window15);
                window10 = create_window10();
		gtk_widget_show(window10);
}


void
on_button47_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window16;
                GtkWidget *window17;
                window16 = lookup_widget(objet_graphique,"window16");
                gtk_widget_hide(window16);
                window17 = create_window17();
		gtk_widget_show(window17);
}


void
on_button48_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		
GtkWidget *window16;
                GtkWidget *window18;
                window16 = lookup_widget(objet_graphique,"window16");
                gtk_widget_hide(window16);
                window18 = create_window18();
		gtk_widget_show(window18);
}


void
on_button49_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window16;
                GtkWidget *window19;
                window16 = lookup_widget(objet_graphique,"window16");
                gtk_widget_hide(window16);
                window19 = create_window19();
		gtk_widget_show(window19);

Capteur c;
	char fichier_capteur[]="fichier_capteur.txt";
	GtkWidget *label62;
	label62= lookup_widget(GTK_WIDGET(window19),"label62");
	char temp[10000]="";
	char buf[200]="";	
	char buf0[50]="NOM: ";
	char buf1[50]="DESIGNATION: ";
	
	
FILE*f;
f=fopen(fichier_capteur,"rb");
if(f!=NULL)
{
strcpy (c.nom," " ) ;
strcpy(c.designation," ");








   fread(&c,sizeof(Capteur),1,f);
   do
  {
   sprintf(buf,"%s%s %s%s ",buf0,c.nom,buf1,c.designation);
 strcat(temp,buf);
strcat(temp,"\n");
 } while(((fread(&c,sizeof(Capteur),1,f))!=0)&&(feof(f)!=1));
}

fclose(f);

gtk_label_set_text(GTK_LABEL(label62),temp);







}


void
on_button50_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window16;
                GtkWidget *window20;
                window16 = lookup_widget(objet_graphique,"window16");
                gtk_widget_hide(window16);
                window20 = create_window20();
		gtk_widget_show(window20);	
}


void
on_button51_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window16;
                GtkWidget *window21;
                window16 = lookup_widget(objet_graphique,"window16");
                gtk_widget_hide(window16);
                window21 = create_window21();
		gtk_widget_show(window21);
}


void
on_button52_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

		GtkWidget *window16;
                GtkWidget *window2;
                window16 = lookup_widget(objet_graphique,"window16");
                gtk_widget_hide(window16);
                window2 = create_window2();
		gtk_widget_show(window2);

}


void
on_button53_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

Capteur c;

	char fichier_capteur;
	
	GtkWidget *entry20;
	GtkWidget *entry21;
	
	

	entry20= lookup_widget(objet_graphique,"entry20");
	entry21= lookup_widget(objet_graphique,"entry21");
	

	
	strcpy(c.nom,gtk_entry_get_text(GTK_ENTRY(entry20)));
	strcpy(c.designation,gtk_entry_get_text(GTK_ENTRY(entry21)));
	
       	

        
	Enregistrer_capteur("fichier_capteur.txt",&c);
}







void
on_button54_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window17;
                GtkWidget *window16;
                window17 = lookup_widget(objet_graphique,"window17");
                gtk_widget_hide(window17);
                window16 = create_window16();
		gtk_widget_show(window16);
}


void
on_button55_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

}


void
on_button56_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window18;
                GtkWidget *window16;
                window18 = lookup_widget(objet_graphique,"window18");
                gtk_widget_hide(window18);
                window16 = create_window16();
		gtk_widget_show(window16);
}


void
on_button57_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window19;
                GtkWidget *window16;
                window19 = lookup_widget(objet_graphique,"window19");
                gtk_widget_hide(window19);
                window16 = create_window16();
		gtk_widget_show(window16);
}


void
on_button58_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

}


void
on_button59_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window20;
                GtkWidget *window16;
                window20 = lookup_widget(objet_graphique,"window20");
                gtk_widget_hide(window20);
                window16 = create_window16();
		gtk_widget_show(window16);
}


void
on_button60_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{

}


void
on_button61_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window21;
                GtkWidget *window16;
                window21 = lookup_widget(objet_graphique,"window21");
                gtk_widget_hide(window21);
                window16 = create_window16();
		gtk_widget_show(window16);
}


void
on_button62_clicked                    (GtkWidget      *objet_graphique,
                                        gpointer         user_data)
{
		GtkWidget *window22;
                GtkWidget *window10;
                window22 = lookup_widget(objet_graphique,"window22");
                gtk_widget_hide(window22);
                window10 = create_window10();
		gtk_widget_show(window10);
}

